<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>事件处理</title>
  <script src="vue.js"></script>
</head>

<body>
  <div id="app">
    数1：<input type="text" v-model="num1">
    数2：<input type="text" v-model="num2">
    <button @click="add">加</button>
    <p>{{result}}</p>
  </div>

  <script>
    const vm = Vue.createApp({
      data() {
        return {
          num1: 0,
          num2: 0,
          result: 0
        }
      },
      methods: {
        add(event) {
          this.result = parseFloat(this.num1) + parseFloat(this.num2);
        }
      }
    });
    vm.mount('#app')
  </script>
</body>

</html>